﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace mForum.Web.Common.Infrastructure.AssetManager.Handlers
{
    public class ScriptHandler : AssetHandlerBase
    {
        public const string ContentType = "text/javascript";

        protected override void SetupResponse(IHttpContextProvider context, string responseContent)
        {
            context.Response.ContentType = ContentType;
            base.SetupResponse(context, responseContent);
        }

        protected override string GetAssetType()
        {
            return AssetType.Script;
        }

        protected override bool IsFileAllowed(string file)
        {
            return Path.GetExtension(file) == ".js";
        }

        protected override string TransformFilePath(string file)
        {
            return AssetType.GetBasePathForType(AssetType.Script) + file;
        }
    }
}
